<?php

/**
 * 
 * @project     : innoTweets 1.0
 * @author      : Dino (DBK)
 * 
 * @package     : Download
 * @description : All File Download
 * 
 */
if (!defined('BASEPATH')) {
  exit('No direct script access allowed');
}

class Download extends CI_Controller {

  public function firefox_addon() {
    $filename = FCPATH . 'extras/addon/firefox/innoTweetsNotify/innotweetsnotify.xpi';
    header("Content-Disposition: filename={$filename}");
    header('Content-type: application/x-xpinstall');
    header('Content-Length: ' . filesize($filename));
    readfile($filename);
  }

  public function database() {
    $filename = $this->db->database . '_' . date('d_m_Y_H_i_s') . '.sql';
    $filename_path = FCPATH . 'assets/temp/' . $filename;
    $command = "mysqldump --opt -h" . $this->db->hostname . " -u" . $this->db->username . " -p" . $this->db->password . " " . $this->db->database . " > " . $filename_path;
    @system($command);
    header("Content-Disposition: filename={$filename}");
    Header('Content-type: application/octet-stream');
    header('Content-Length: ' . filesize($filename_path));
    readfile($filename_path);
  }

}
